import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home/dashboard'
  },
  {
    path: '/home',
    name: 'home',
    meta: { title: '首页', icon: 'icon-panel', type: "2" },
    component: layout,
    children: [
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue'), meta: { title: '仪表盘', type: "2" }
      },
      {
        path: 'data',
        name: 'data',
        component: () => import(/* webpackChunkName: "data" */ '../views/dashboard/data.vue'), meta: { title: '设备数据', type: "2" }
      },
    ]
  },

  {
    path: '/device',
    name: 'device',
    component: layout,
    meta: { title: '设备', icon: 'icon-luyouqi', type: "2" },
    children: [
      { path: "gateway", name: "gateway", component: () => import(/* webpackChunkName: "gateway" */ '../views/device/gateway.vue'), meta: { title: '网关' }, type: "2" },
      { path: "groupleader", name: "groupleade", component: () => import(/* webpackChunkName: "groupleade" */ '../views/device/GroupLeader.vue'), meta: { title: '设备群主' } },
      { path: "sensor", name: "sensor", component: () => import(/* webpackChunkName: "sensor" */ '../views/device/SenSor.vue'), meta: { title: '传感器列表' }, type: "2" },
    ]
  },
  {
    path: '/fee',
    name: 'fee',
    meta: { title: '计费', icon: 'icon-fyxx', type: "2" },
    component: layout,
    children: [
      { path: "zhangHao", name: "zhangHao", component: () => import(/* webpackChunkName: "zhangHao" */ '../views/fee/zhangHao.vue'), meta: { title: '账户信息' }, type: "2" },
      { path: "rechargeList", name: "rechargeList", component: () => import(/* webpackChunkName: "rechargeList" */ '../views/fee/rechargeList.vue'), meta: { title: '充值记录' }, type: "2" },
      { path: "usageList", name: "usageList", component: () => import(/* webpackChunkName: "usageList" */ '../views/fee/usageList.vue'), meta: { title: '使用记录' }, type: "2" }
    ]
  },
  {
    path: '/measurement',
    name: 'measurement',
    meta: { title: '测量类型', icon: 'icon-signal', type: "2" },
    component: layout,
    children: [
      { path: "tianJia", name: "tianJia", component: () => import(/* webpackChunkName: "tianJia" */ '../views/measurement/tianJia.vue'), meta: { title: '添加测量类型' }, type: "2" },
      { path: "leiXing", name: "leiXing", component: () => import(/* webpackChunkName: "leiXing" */ '../views/measurement/leiXing.vue'), meta: { title: '测量类型列表' }, type: "2" }
    ]
  },
  {
    path: '/security',
    name: 'security',
    meta: { title: '安全', icon: 'icon-anquan', type: "2" },
    component: layout,
    children: [
      { path: "tianJia", name: "tianJia", component: () => import(/* webpackChunkName: "tianJia" */ '../views/security/tianJia.vue'), meta: { title: '添加密钥' }, type: "2" },
      { path: "lieBiao", name: "lieBiao", component: () => import(/* webpackChunkName: "lieBiao" */ '../views/security/lieBiao.vue'), meta: { title: '密钥列表' }, type: "2" }
    ]
  },
  {
    path: '/account',
    name: 'account',
    meta: { title: '账号', icon: 'icon-account', type: "1" },
    component: layout,
    children: [
      { path: "addaccount", name: "addaccount", component: () => import(/* webpackChunkName: "addaccount" */ '../views/account/addaccount.vue'), meta: { title: '账号列表' }, type: "1" },
      { path: "listaccount", name: "listaccount", component: () => import(/* webpackChunkName: "listaccount" */ '../views/account/listaccount.vue'), meta: { title: '添加账号' }, type: "1" }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  {
    path: '*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  },
]

const router = new VueRouter({
  routes
})

export default router
